Previous Book Contents Book Index Next

Inside Macintosh: Mac OS 8 Toolbox Reference /
Chapter 2 - Control Manager Reference / Control Manager Functions
Defining Your Own User Pane Functions /


MyUserPaneKeyDownProc

NEW WITH THE APPEARANCE MANAGER

Handles keyboard event processing.

The Control Manager declares the type for an application-defined user pane key down function as follows:

typedef pascalControlPartCode(*ControlUserPaneKeyDownProc)(
                                 ControlHandle control
                                 SInt16 keyCode,
                                 SInt16 charCode,
                                 SInt16 modifiers);
The Control Manager defines the data type UserPaneKeyDownUPP to identify the universal procedure pointer for this application-defined function:

typedef UniversalProcPtr ControlUserPaneKeyDownUPP;
You typically use the NewControlUserPaneKeyDownProc macro like this:

ControlUserPaneKeyDownUPP myControlUserPaneKeyDownUPP;
myControlUserPaneKeyDownUPP = NewControlUserPaneKeyDownProc
(MyUserPaneKeyDown);

You typically use the CallControlUserPaneKeyDownProc macro like this:

CallControlUserPaneKeyDownProc(myControlUserPaneKeyDownUPP, control, keyCode, charCode, modifiers);

Here's how to declare the function MyUserPaneKeyDownProc:

pascal ControlPartCode MyUserPaneKeyDownProc (
                     ControlHandle control, 
                     SInt16 keyCode, 
                     SInt16 charCode,
                     SInt16 modifiers);
control
A handle to the control in which the keyboard event occurred.
keyCode
The virtual key code derived from event structure. This value represents the key pressed or released by the user. It is always the same for a specific physical key on a particular keyboard regardless of which modifier keys were also pressed.
charCode
A particular character derived from the event structure. This value depends on the virtual key code, the state of the modifier keys, and the current 'KCHR' resource.
modifiers
The constant in the modifiers field of the event structure specifying the state of the modifier keys and the mouse button at the time the event was posted.
function result
Returns the part code of the control where the keyboard event occurred. If the keyboard event did not occur in a control, your function should return kControlNoPart.
DISCUSSION
Your MyUserPaneKeyDownProc function should handle the key pressed or released by the user and return the part code of the control where the keyboard event occurred. This function will only get called if you've set the kControlSupportsFocus feature bit on creation of the user pane control. Once you have created the function MyUserPaneKeyDownProc, pass kControlUserPaneKeyDownProcTag in the tagName parameter of SetControlData.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
8 JAN 1998